
#include "PCH.h"
#include "Vector.h"

void CVector::Normalize()
{
	double Divider = //FastInvSqrt((double)(x*x+y*y+z*z));
						1/sqrt(x*x+y*y+z*z);
	x*=Divider;
	y*=Divider;
	z*=Divider;
}

double CVector::DotProduct(const CVector& Vect2) const
{
	return (x*Vect2.x+y*Vect2.y+z*Vect2.z);
}

double CVector::Distance(const CVector& Vect2) const
{
	double a = x-Vect2.x;
	double b = y-Vect2.y;
	double c = z-Vect2.z;

	return(sqrt(a*a+b*b+c*c));
}

CVector CVector::CrossProduct(const CVector& Vect2) const
{
	CVector cp;
	cp.x = y*Vect2.z-z*Vect2.y;
	cp.y = z*Vect2.x-x*Vect2.z;
	cp.z = x*Vect2.y-y*Vect2.x;
	return cp;
}

